/******************************************************
*  Copyright(c) pages.ilovezxl.top
*  FileName : salagent.c
*  Author : rivulet.dave
*  Description : SAL接口文件
*  Data : 2020-07-07
******************************************************/


/*********************************************************************
 * INCLUDES
 */

#include "stdrope.h"

#include "sallib.h"
#include "salagent.h"

#include "thread.h"
#include "threadasync.h"
#include "mem.h"
#include "log.h"
#include "fs.h"
#include "ostime.h"
#include "cli.h"
#include "ostmr.h"
#include "anysock.h"
#include "cfg.h"

/*********************************************************************
 *  EXTERNAL VARIABLES
 */

/*********************************************************************
 * MACROS
 */

/*********************************************************************
 * TYPES
 */


/*********************************************************************
 * FUNCTIONS DECLARE
 */

/*********************************************************************
 * VARIABLES
 */


/*********************************************************************
 * FUNCTIONS
 */

/**
 *   @Description: SAL层部分模块优先安装
 *   @param : NA
 *   @return : _OK/_ERR
 */
int32_t SAL_PreInstall(void)
{
    osInstall();
    osThreadAsyncInstall();

#if (SAL_LOG == _ENABLE)
    LOG_Init(LOG_LEVEL_DEBUG);
#endif

#if (SAL_TIME == _ENABLE)
    osTimeInstall();
#endif

    return _OK;
}

/**
 *   @Description: SAL层模块安装
 *   @param : NA
 *   @return : _OK/_ERR
 */
int32_t SAL_MainInstall(void)
{
#if (SAL_OSTMR == _ENABLE)
    osTimerInstall();
#endif

#if (SAL_SOCK == _ENABLE)
    osSocketInstall();
#endif

#if (SAL_CLI == _ENABLE)
    CLI_Install();
#endif

#if (SAL_FS == _ENABLE)
    fsInstall();
#endif

    CFG_Install();
    return _OK;
}

/**
 *   @Description: SAL层模块卸载
 *   @param : NA
 *   @return:_OK/_ERR
 */
int32_t SAL_Uninstall(void)
{
    CFG_Uninstall();

#if (SAL_FS == _ENABLE)
    fsUninstall();
#endif

#if (SAL_CLI == _ENABLE)
    CLI_Uninstall();
#endif

#if (SAL_SOCK == _ENABLE)
    osSocketUninstall();
#endif

#if (SAL_OSTMR == _ENABLE)
    osTimerUninstall();
#endif

#if (SAL_TIME == _ENABLE)
    osTimeUninstall();
#endif

    osThreadAsyncUninstall();
    osUninstall();
    return _OK;
}

/************************************** The End Of File **************************************/

